home *** CD-ROM | disk | FTP | other *** search
/ Champak 114 / Vol 114.iso / games / park_thi.swf / scripts / DefineSprite_648 / frame_1 / DoAction.as
Encoding:
Text File  |  2010-08-12  |  1.3 KB  |  32 lines

  1. function checkCollision(mc2, mc1, tolerance, scope)
  2. {
  3.    var _loc1_ = classes.CollisionDetection.checkForCollision(mc1,mc2,255);
  4.    return _loc1_;
  5. }
  6. var scope = _parent;
  7. var tolerance = 120;
  8. onEnterFrame = function()
  9. {
  10.    if(this.hitTest(_parent[_root.userCar].target_mc))
  11.    {
  12.       if(checkCollision(this,_parent[_root.userCar]) != undefined || checkCollision(this,_parent[_root.userCar]) != null)
  13.       {
  14.          _root.crash_snd.start();
  15.          _parent[_root.userCar].hit = true;
  16.          _parent[_root.userCar].speed = (- _parent[_root.userCar].speed) * 1.5;
  17.          _parent[_root.userCar].vector[0] = - _parent[_root.userCar].vector[0];
  18.          _parent[_root.userCar].vector[1] = - _parent[_root.userCar].vector[1];
  19.          _parent[_root.userCar]._x += _parent[_root.userCar].vector[0] += (Math.cos(_parent[_root.userCar].angle) * _parent[_root.userCar].speed - _parent[_root.userCar].vector[0]) / _parent[_root.userCar].traction;
  20.          _parent[_root.userCar]._y += _parent[_root.userCar].vector[1] += (Math.sin(_parent[_root.userCar].angle) * _parent[_root.userCar].speed - _parent[_root.userCar].vector[1]) / _parent[_root.userCar].traction;
  21.       }
  22.       else
  23.       {
  24.          _parent[_root.userCar].hit = false;
  25.       }
  26.    }
  27.    else
  28.    {
  29.       _parent[_root.userCar].hit = false;
  30.    }
  31. };
  32.